:root {
  --fx-green: #00463e;
  --fx-green-dark: #002c27;
  --fx-green-deep: #001d1a;
  --fx-green-mid: #006257;
  --fx-green-soft: #dce9e6;
  --line-green: #00463e;
  --sell-red: #a61919;
  --panel-gray: #f4f5f7;
  --border-gray: #b7bcc0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--fx-green-deep);
  color: #333;
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.window-frame {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--fx-green-dark);
  border: 4px solid var(--fx-green);
  border-radius: 6px;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.14);
}

.title-bar {
  flex-shrink: 0;
  min-height: 28px;
  background: linear-gradient(to bottom, #007165 0%, var(--fx-green) 48%, #002f2a 52%, var(--fx-green-dark) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--fx-green-deep);
}

.title-bar-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 2px #000;
  white-space: nowrap;
}

.title-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.connection-label {
  max-width: 280px;
  overflow: hidden;
  color: #d7efeb;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  text-shadow: 0 1px 1px #000;
  white-space: nowrap;
}

.title-action-btn {
  height: 20px;
  padding: 0 8px;
  background: linear-gradient(to bottom, #00665b 0%, var(--fx-green) 100%);
  border: 1px solid #008173;
  color: #fff;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.title-action-btn:hover,
.title-action-btn:focus-visible {
  background: linear-gradient(to bottom, #008276 0%, #00584f 100%);
  outline: none;
}

.controls-bar {
  flex-shrink: 0;
  min-height: 32px;
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  background: linear-gradient(to bottom, var(--fx-green) 0%, var(--fx-green-deep) 100%);
  border-bottom: 2px solid #00110f;
}

.button-group {
  display: flex;
  align-items: stretch;
  height: 32px;
  flex-shrink: 0;
}

.mobile-view-group {
  display: none;
}

.control-btn {
  height: 100%;
  min-width: 52px;
  padding: 0 12px;
  background: linear-gradient(to bottom, #00665b 0%, var(--fx-green) 100%);
  color: #d7efeb;
  border: 0;
  border-right: 1px solid #008173;
  border-radius: 0;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.control-btn:hover,
.control-btn:focus-visible,
.control-btn.is-active {
  background: linear-gradient(to bottom, #008276 0%, #00584f 100%);
  color: #fff;
  outline: none;
}

.control-btn:focus-visible {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.38);
}

.control-btn.is-locked {
  color: rgba(215, 239, 235, 0.45);
  cursor: not-allowed;
  position: relative;
}

.control-btn.is-locked::after {
  content: "";
  position: absolute;
  right: 5px;
  top: 5px;
  width: 4px;
  height: 4px;
  background: #d7efeb;
  border-radius: 50%;
  opacity: 0.7;
}

.app-alert {
  flex-shrink: 0;
  min-height: 24px;
  display: flex;
  align-items: center;
  background: #f7efe2;
  border-bottom: 1px solid #caa66f;
  color: #6b4310;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
}

.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 1px;
  background: #8e959b;
}

.charts-column {
  --top-chart-size: 50%;
  flex: 0 0 65%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #8e959b;
}

.sidebar-column {
  flex: 0 0 35%;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #e3e6e8;
}

.panel-header {
  flex-shrink: 0;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: linear-gradient(to bottom, #eceeef 0%, #cfd3d7 50%, #b8bcc1 100%);
  border-bottom: 1px solid #9ea3a8;
  color: #2b353e;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
}

.panel-title,
.panel-header-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-header-sub {
  color: #555e66;
  font-size: 10px;
  font-weight: 400;
}

.chart-section {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel-gray);
  position: relative;
}

.chart-section-primary {
  flex: 0 0 var(--top-chart-size);
}

.chart-section-secondary {
  flex: 1 1 0;
}

.chart-resizer {
  flex: 0 0 6px;
  cursor: row-resize;
  background: linear-gradient(to bottom, #006257, var(--fx-green));
  border-top: 1px solid #8e959b;
  border-bottom: 1px solid #8e959b;
  position: relative;
}

.chart-resizer::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 2px;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.6);
  border-radius: 1px;
}

.chart-resizer:hover,
.chart-resizer:focus-visible {
  background: linear-gradient(to bottom, #008276, #00584f);
  outline: none;
}

.tv-container {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  position: relative;
}

.chart-legend {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 3;
  max-width: calc(100% - 16px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 7px;
  background: rgba(244, 245, 247, 0.92);
  border: 1px solid rgba(130, 139, 146, 0.72);
  color: #1f2a2e;
  font-size: 10px;
  line-height: 1.25;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.chart-legend-title,
.chart-legend-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-legend-title {
  font-weight: 700;
}

.chart-legend-value {
  color: var(--fx-green);
  font-family: Consolas, "Courier New", monospace;
  font-weight: 700;
}

.chart-fallback {
  height: 100%;
  display: none;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    0deg,
    var(--panel-gray) 0,
    var(--panel-gray) 23px,
    #e5e7eb 24px
  );
  color: #40464c;
  font-size: 12px;
}

.sidebar-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #f1f2f4;
  padding: 0;
}

.tape-wrapper {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: #fff;
  border: 0;
  scrollbar-width: thin;
  scrollbar-color: #99aaa6 #e8eaed;
}

.tape-wrapper::-webkit-scrollbar {
  width: 6px;
}

.tape-wrapper::-webkit-scrollbar-track {
  background: #e8eaed;
}

.tape-wrapper::-webkit-scrollbar-thumb {
  background-color: #99aaa6;
  border-radius: 3px;
}

.tape-wrapper::-webkit-scrollbar-thumb:hover {
  background-color: #758a85;
}

.tape-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.tape-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(to bottom, #f2f3f5, #d2d5d8);
  border-bottom: 1px solid var(--border-gray);
  color: #333;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 6px;
  text-align: right;
}

.tape-table th:first-child {
  text-align: left;
}

.tape-table td {
  border-bottom: 1px solid #f0f2f4;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.3;
  padding: 4px 6px;
  text-align: right;
}

.tape-table td:first-child {
  color: #555;
  font-family: Arial, Helvetica, sans-serif;
  text-align: left;
}

.side-short {
  color: var(--sell-red);
  font-weight: 700;
}

.side-long {
  color: var(--line-green);
  font-weight: 700;
}

.empty-row td {
  color: #6b747c;
  font-family: Arial, Helvetica, sans-serif;
  padding: 16px 8px;
  text-align: center;
}

.app-footer {
  flex-shrink: 0;
  min-height: 26px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: linear-gradient(to bottom, var(--fx-green) 0%, var(--fx-green-deep) 100%);
  border-top: 1px solid #007165;
  color: #b7d8d3;
  font-size: 10px;
  padding: 6px 10px;
}

.data-feed-notice {
  color: #dcf2ee;
  text-decoration: none;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 29, 26, 0.88);
  padding: 18px;
}

.login-panel {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #eef2f1;
  border: 4px solid var(--fx-green);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.38);
  padding: 18px;
}

.login-title {
  color: #102522;
  font-size: 15px;
  font-weight: 700;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: #33413e;
  font-size: 11px;
  font-weight: 700;
}

.login-field input {
  height: 32px;
  border: 1px solid #9ba8a5;
  color: #16211f;
  font: inherit;
  font-size: 13px;
  padding: 0 9px;
}

.login-field input:focus {
  border-color: var(--fx-green);
  box-shadow: 0 0 0 2px rgba(0, 70, 62, 0.16);
  outline: none;
}

.login-button {
  height: 34px;
  background: linear-gradient(to bottom, #00665b 0%, var(--fx-green) 100%);
  border: 1px solid #008173;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.login-button:hover,
.login-button:focus-visible {
  background: linear-gradient(to bottom, #008276 0%, #00584f 100%);
  outline: none;
}

.login-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.auth-message {
  min-height: 16px;
  color: #6b4310;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

@media (max-width: 1100px), (hover: none) and (pointer: coarse) and (max-width: 1366px) {
  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
  }

  .window-frame {
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
    border-width: 4px;
  }

  .title-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .title-bar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .connection-label {
    max-width: none;
  }

  .controls-bar {
    height: auto;
    flex-wrap: wrap;
  }

  .mobile-view-group {
    display: flex;
  }

  .button-group {
    flex: 1 1 100%;
    min-width: 100%;
    height: 32px;
  }

  .control-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 6px;
  }

  .workspace {
    flex: 1;
    min-height: 0;
    height: auto;
    flex-direction: column;
  }

  .chart-resizer {
    display: none;
  }

  .charts-column {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
  }

  .chart-section-primary,
  .chart-section-secondary {
    flex: 1 1 0;
  }

  .sidebar-column {
    flex: 1 1 auto;
    width: 100%;
    height: 100%;
  }

  .window-frame[data-mobile-view="analytics"] .charts-column {
    display: flex;
  }

  .window-frame[data-mobile-view="analytics"] .sidebar-column {
    display: none;
  }

  .window-frame[data-mobile-view="tape"] .charts-column {
    display: none;
  }

  .window-frame[data-mobile-view="tape"] .sidebar-column {
    display: flex;
  }
}
